package com.yc.bigdata.flink.demo3.task;

import com.yc.bigdata.flink.demo3.util.Property;

import org.apache.flink.api.java.utils.ParameterTool;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

import java.util.Properties;

/**
 * <p></p>
 *
 * @author: YuanChilde
 * @date: 2020-02-15 11:24
 * @version: 1.0
 * Modification History:
 * Date    Author      Version     Description
 * -----------------------------------------------------------------
 * 2020-02-15 11:24    YuanChilde     1.0        新增
 */
public class NginxLogTask {

    public static void main(String[] args) {
       // String[] args1 = {"--port","9111"};
        int port;
        try{
            ParameterTool parameterTool = ParameterTool.fromArgs(args);
            port = parameterTool.getInt("port");
        }catch (Exception e){
            System.err.println("No port specified. Please run 'SocketWindowWordCount --port <port>'");
            System.exit(-1);
        }

        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

        Properties properties = Property.getKafkaProperties("log");

        /*DataStreamSource<String> dataStream = env.addSource(new FlinkKafkaConsumer<String>("con", new SimpleStringSchema(), properties));
        dataStream.map(new LogMapFunction());

        env.execute("Log message receive to cassandra");

        String[] args1 = {"--port","9111"};
        int port;
        try{
            ParameterTool parameterTool = ParameterTool.fromArgs(args1);
            port = parameterTool.getInt("port");
        }catch (Exception e){
            System.err.println("No port specified. Please run 'SocketWindowWordCount --port <port>'");
            port = 9111;
        }*/
    }
}
